package com.rong.distributed.transaction.mq;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import com.rong.distributed.transaction.mq.bean.Message;

/**
 * mq消息存储着
 * 
 * @author liurong
 *
 */
public class MessageStore {
	private static final MessageStore MESSAGE_STORE = new MessageStore();

	/**
	 * message缓存，key：messageId, value:message
	 */
	private Map<String, Message> MESSAGE_CACHE = new ConcurrentHashMap<String, Message>();

	private MessageStore() {

	}

	public static MessageStore getInstance() {
		return MESSAGE_STORE;
	}

	public void putMessage(Message message) {
		MESSAGE_CACHE.put(message.getId(), message);
	}

	public Message removeMessage(String messageId) {
		return MESSAGE_CACHE.remove(messageId);
	}
}
